package cn.richx.pushmessage.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 部门表
 *
 * @author: Xiumin
 * @create: 2018/3/30
 */
@Entity
@Table(name = "kf_department")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Department extends AbstractAuditingEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @NotNull
    @Size(max = 20)
    @Column(name = "name", length = 20)
    private String name;    // 部门名称

    @Size(max = 100)
    @Column(name = "parentIds", length = 100)
    private String parentIds; // 所有父级编号

    @Size(max = 2)
    @JsonIgnore
    @Column(name = "status", length = 2)
    private int status;    // 状态标记（0：正常；1：删除）

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Size(max = 10)
    @Column(name = "code", length = 10)
    private String code;    // 部门编码

    @NotNull
    @Size(max = 10)
    @Column(name = "type", length = 10)
    private int type;    // 部门类型（1：基地；2：总经理；3：中心；4：部门）

    @NotNull
    @ManyToOne(fetch = FetchType.EAGER)
    @JsonBackReference
    @JoinColumn(name = "area_id")
    private Area area;

    @NotNull
    @Size(max = 255)
    @Column(name = "introduction", length = 255)
    private String introduction; // 联系介绍

    @NotNull
    @Size(max = 20)
    @Column(name = "phone", length = 20)
    private String phone;    // 电话

    @NotNull
    @Size(max = 255)
    @Column(name = "mark", length = 255)
    private String mark;    // 备注

    @ManyToOne(fetch = FetchType.EAGER)
    @JsonBackReference
    @JoinColumn(name = "parent")
    private Department parent;
    @Size(max = 10)
    @Column(name = "sort", length = 10)
    private int sort;

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Department getParent() {
        return parent;
    }

    public void setParent(Department parent) {
        this.parent = parent;
    }

    public String getParentIds() {
        return parentIds;
    }

    public void setParentIds(String parentIds) {
        this.parentIds = parentIds;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
